package top.kaoshanji.r1ch04a.config;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import top.kaoshanji.r1ch04a.binarytea.BinaryTeaApplication;

/**
 * 代码清单test-r1ch04a-82页b：自动配置类无效
 * @author kaoshanji
 * ^_^
 * create time 2025/5/28 17:51
 */
@SpringBootTest(classes = BinaryTeaApplication.class, properties = {"binarytea.ready=false"})
public class ShopConfigurationDisableTest {

    @Autowired
    private ApplicationContext applicationContext;

    @Test
    public void testPropertiesBeanUnavailable() {
        Assertions.assertEquals("false", applicationContext.getEnvironment().getProperty("binarytea.ready"));
        Assertions.assertFalse(applicationContext.containsBean("binarytea-top.kaoshanji.r1ch04a.binarytea.BinaryTeaProperties"));

    }

}
